package net.jwt.springjdbcmybatisplus.dao;

import net.jwt.springjdbcmybatisplus.entity.Stu;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface StuDaoByMyBatis extends StuDao{

    @Select("select * from stu where username=#{username} and pass=#{pass}")
    Stu loginConfirm(@Param("username") String username,@Param("pass") String pass);

    @Delete("delete stu where id=#{id}")
    int remove(@Param("id") long id);

    @Insert("insert into stu (username,pass,java,math,os) values(#{username},#{pass},#{java}," +
            "#{math},#{os})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    int add(Stu stu);

    @Select("select * from stu")
    List<Stu> list();
    @Select("select * from stu where id=#{id}")
    Stu findById(@Param("id") long id);
}
